//客户筛选管理CreateInfo.js  网格下的内容控件 ProjectSource.js

var ProjectSourceDemo = function(){
	
	var userSelector = null;
	var selectUserId = [];
	
	var pactID=new  Ext.form.TextField({
		fieldLabel : '合同编号',
		width : 150,
		disabled:true
	});
	
	var customerID = new Ext.form.TextField({
		fieldLabel : '客户编号',
		width : 150,
		disabled:true
	});
	var customerName = new Ext.form.TextField({
		fieldLabel : '客户名称',
		width : 300,
		disabled:true,
		allowBlank : false
	});
	var customerArea = new Ext.form.ComboBox( {
		fieldLabel : '所属区域',
		store: OMS.AREA,
		mode : 'local',
		displayField : 'name',
		triggerAction : 'all',
		editable : false,
		valueField : 'id',
		typeAhead : true,
		width : 150,
		emptyText : '---请选择---',
		selectOnFocus : true
	});
	this.renderprojectType = function(value){
		return OMS.PROJECTTYPEOBJECT[value];
	};
	var pactType = new Ext.form.ComboBox( {
		fieldLabel : '合同类型',
		store : OMS.PACTTYPE,
		mode : 'local',
		displayField : 'name',
		triggerAction : 'all',
		editable : false,
		valueField : 'id',
		typeAhead : true,
		width : 150,
		emptyText : '---请选择---',
		selectOnFocus : true,
		allowBlank : false
	});
	var pactMoney = new Ext.form.NumberField({
		fieldLabel : '合同金额',
		width : 150
	});
	var pactEndDate = new Ext.form.DateField( {
		fieldLabel : '至',
		format : 'Y-m-d',
		width : 150
	});
	var pactStartDate = new Ext.form.DateField( {
		fieldLabel : '合同期限',
		format : 'Y-m-d',
		width : 150
	});
	var pactName = new Ext.form.TextField({
		fieldLabel : '合同名称',
		width : 300,
		allowBlank : false
	});
	var pactMoneyType = new Ext.form.ComboBox( {
		fieldLabel : '付款类型',
		//hiddenName : 'type',
		store : OMS.PACTMONEYTYPE,
		mode : 'local',
		displayField : 'name',
		triggerAction : 'all',
		editable : false,
		valueField : 'id',
		typeAhead : true,
		width : 150,
		emptyText : '---请选择---',
		selectOnFocus : true,
		allowBlank : false
	});
	var pactSuccessName = new Ext.form.TextField({
		fieldLabel : '签约人',
		width : 120,
		allowBlank : false
	});
	var pactSuccessDate = new Ext.form.DateField( {
		fieldLabel : '签约日期',
		format : 'Y-m-d',
		width : 150
	});
	// 合同基本信息-----end
	this.projectInfo = new Ext.form.FieldSet({
		title : '基础信息',
		collapsible : true,
		autoHeight : true,
		width : 930,
		items : [{layout:'column',
				  defaults:{layout:'form'},
				  items:[{columnWidth:0.3,items:[pactID]},
				         {columnWidth:0.5,items:[customerName]}]},
				  {layout:'column',
				   defaults:{layout:'form',columnWidth:0.3},
				   items:[{items:[customerArea,pactStartDate]},
						  {items:[pactType,pactEndDate]},
						  {items:[pactMoney]}]},
				   {xtype:'fieldset',title:'合同明细',collapsible:true,autoHeight:true,
					items:[{layout:'column',
						   defaults:{layout:'form'},
						   items:[{columnWidth:0.3,items:[pactSuccessName]},
							      {columnWidth:0.5,items:[pactName]}
						  		 ]},
						  {layout:'column',
						   defaults:{layout:'form'},
						   items:[{columnWidth:0.3,items:[pactMoneyType]},
								  {columnWidth:0.3,items:[pactSuccessDate]}
								  ]}
						  ]}
				]
	});
	

	
	var projectCustNeedItems = new Ext.form.CheckboxGroup({
	    xtype: 'checkboxgroup',
	    fieldLabel: '客户需求',
	    itemCls: 'x-check-group-alt',
	    columns: 4,
	    width : 500,
	    items: [
	        {boxLabel: '基础配套建设', name: 'cust4-1',value:'1'},
	        {boxLabel: '通信配套建设', name: 'cust4-2',value:'2'},
	        {boxLabel: '专线', name: 'cust4-3',value:'3'},
	        {boxLabel: '语音类', name: 'cust4-4',value:'4'}
	    ]
	});
	
	var projectOther = new Ext.form.TextField({
		fieldLabel : '其他',
		width : 120
	});
	
	var projectNeedServer = new Ext.form.TextArea({
		fieldLabel : '服务要求',
		width : 800
	});
	
	var projectNeedFunction = new Ext.form.TextArea({
		fieldLabel : '实现功能',
		width : 800
	});
	
	var projectNeedBus = new Ext.form.TextArea({
		fieldLabel : '业务提供',
		width : 800
	});
	
	var projectNeedSummary = new Ext.form.TextArea({
		fieldLabel : '备注',
		width : 800
	});
	
	// 需求信息元素----end
	
	this.projectNeed = new Ext.form.FieldSet({
		title : '需求信息',
		collapsible : true,
		autoHeight : true,
		width : 930,
		items : [
		         {layout:'column',
				  defaults:{layout:'form'},
				  items:[{columnWidth:0.75,items:[projectCustNeedItems]},
				         {columnWidth:0.25,items:[projectOther]}]
				  },projectNeedServer,projectNeedFunction,projectNeedBus,projectNeedSummary
		        ]
	});
	
	this.projectIsVs = new Ext.form.Checkbox({
		boxLabel: '是否有竞争对手',
		scope : this,
	    listeners : {
			scope : this,
			check : function(thiz,checked){
				if(checked)
					this.projectVsInfo.show();
				else
					this.projectVsInfo.hide();
			}
		}
	});
	


	//为控件设置值
	this.setCompValueAndDisabled = function(data){
		customerID.setValue(data.id);
		customerName.setValue(data.CustomerName);
		customerArea.setValue(data.Area);


	};
	
	
	//合同信息写入控件
	this.setPactValue = function(data){
		customerID.setValue(data.customerID);
		customerName.setValue(data.customerName);
		customerArea.setValue(data.customerArea);
		pactType.setValue(data.pactType);

		pactMoney .setValue(data.pactMoney);
		pactEndDate .setValue(data.pactEndDate);
		pactStartDate.setValue(data.pactStartDate);
		pactName.setValue(data.pactName);
		pactMoneyType.setValue(data.pactMoneyType);
		pactSuccessName.setValue(data.pactSuccessName);
		pactSuccessDate.setValue(data.pactSuccessDate);
		pactID.setValue(data.pactID);

	};
	
	
	//取得控件里的值 
		this.getpactID=function(){
			value=pactID.getValue();
			return value;
		}
		this.getCustomerId= function(){
			value = customerID.getValue();
			return value;
		};
		
		this.getCustomerName=function(){
			value = customerName.getValue();
			return value;
		};
	
		this.getCustomerArea=function(){
			value = customerArea.getValue();
			return value;
		};
		this.getPactType=function(){
			value=pactType.getValue();
			return value;
		};
		this.getPactMoney=function(){
			value=pactMoney.getValue();
			return value;
		};
		this.getPactEndDate=function(){
			value=pactEndDate.getValue() ? pactEndDate.getValue().format('Y-m-d') : '';
			return value;
		};
		this.getPactStartDate=function(){
			value=pactStartDate.getValue()?pactStartDate.getValue().format('Y-m-d') :'';
			return value;
		};
		this.getPactName=function(){
			value=pactName.getValue();
			return value;
		};
	
		this.getPactMoneyType=function(){
			value=pactMoneyType.getValue();
			return value;
		};
	
		this.getPactSuccessName=function(){
			value=pactSuccessName.getValue();
			return value;
		};
	
		this.getPactSuccessDate=function(){
			value=pactSuccessDate.getValue()?pactSuccessDate.getValue().format('Y-m-d') :'';
			return value;
		};
	
	
};